
var app = getApp();
var c = require('../libs/common.js');
var config=require('../libs/config.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    c.loginVer(this,function(that){
      c.uinfo(that);
      var phone = that.data.uinfo.phone;
      if (phone) {
        var nPhone = phone.substr(0, 3) + '****' + phone.substr(7, 11);
        that.setData({ nPhone: nPhone });
      }
      that.getSystemInfo();
    });
  },
  
  getSystemInfo(){
    c.ajax(
      config.hostapi +'My/getServiceInfo',
      {id:1},
      res=>{
        var content=res.data.data.content;
        this.setData({ content: content})
      }
    )
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    if(wx.getStorageSync('userinfo')){
      this.onLoad();
    }else{
      c.loginVer();
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  inmyingo:function(){
    wx.navigateTo({
      url: '/pages/myinfo/myinfo',
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  kefuclick: function () {
    var content = this.data.content;
    wx.showModal({
      title: '',
      content: content,
      confirmText: '拨打',
      success(res) {
        if (res.confirm) {
          wx.makePhoneCall({
            phoneNumber: content,
          })
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  },
  mycollect:function(){
    wx.navigateTo({
      url: '/pages/mycollect/mycollect',
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  activity:function(){
    wx.navigateTo({
      url: '/pages/activity/activity',
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  open:function(){
    wx.navigateToMiniProgram({
      appId: 'wx816edfafd0997b4f',
      path: '',
      extraData: {
        foo: 'bar'
      },
      envVersion: 'release',
      success(res) {
       console.log('success');
      }
    })
  }
})